package logic

import (
	"context"
	"good_srv/goodclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type RiderContentLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRiderContentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RiderContentLogic {
	return &RiderContentLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RiderContentLogic) RiderContent(req *types.RiderContentRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	order, err := l.svcCtx.GoodSrv.RiderContent(l.ctx, &goodclient.RiderContentRequest{
		RiderId: req.RiderId,
		Content: req.Content,
		Score:   req.Score,
		Image:   req.Image,
		OrderId: req.OrderId,
	})
	if err != nil {
		return &types.Response{
			Mes:  err.Error(),
			Code: 400,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Mes:  "订单评论骑手成功",
		Code: 200,
		Data: order,
	}, nil
}
